<?php

class Familymember_Api_Core extends Core_Api_Abstract {
	public function isFamilyMember($viewer, $user) {
		$row = Engine_Api::_ ()->getDbTable ( 'member', 'familymember' )->fetchRow ( "resource_id = " . $viewer->getIdentity () . " AND user_id = " . $user->getIdentity () );
		
		if (! $row) {
			return 0; // NOT FAMILY MEMBER
		}
		
		if (! $row->approved) {
			return 2; // UNAPPROVED MEMBER
		}
		
		return 1; // APPROVED MEMBER
	}

}